import { UserInfo } from '@/types/user'
const token: string = 'tokenInfo'
const histroyList: string = 'histroyList'
const userKey: string = 'userInfo'

interface Token {
    token: string,
    refresh_token: string
}
export const setToken = (tokenInfo: Token) => localStorage.setItem(token, JSON.stringify(tokenInfo))

export const getToken = (): Token => { return JSON.parse(localStorage.getItem(token) as string) }

export const removeToken = (): void => localStorage.removeItem(token)

export const setHistroyList = (histroyListInfo: {}) => localStorage.setItem(histroyList, JSON.stringify(histroyListInfo))

export const getHistroyList = (): any => JSON.parse(localStorage.getItem(histroyList) || '0')

export const removeHistroyList = (): void => localStorage.removeItem(histroyList)
// 存个人信息吧
export const setUserInfo = (userInfo: UserInfo) => localStorage.setItem(userKey, JSON.stringify(userInfo))

export const getUserInfo = () => { return JSON.parse(localStorage.getItem(userKey) as string) }

export const removeUserInfo = (): void => localStorage.removeItem(userKey)


